


package com.adobe.webapis.flickr.methodgroups {

    import com.adobe.webapis.flickr.events.FlickrResultEvent;
    import com.adobe.webapis.flickr.*;
    import flash.events.Event;
    import flash.net.URLLoader;

        [Event(name="photosInterestingnessGetList",
             type="com.adobe.webapis.flickr.events.FlickrResultEvent")]


    public class Interestingness
    {
        private var _service:FlickrService;
        private var _licenses:Licenses;
        private var _notes:Notes;
        private var _transform:Transform;
        private var _upload:Upload;

        public function Interestingness( service:FlickrService ) {
            _service = service;
            _licenses = new Licenses( service );
            _notes = new Notes( service );
            _transform = new Transform( service );
            _upload = new Upload( service );
        }

        public function getList( date:String = "", extras:String = "", per_page:Number = 100, page:Number = 1 ):void {
            // Let the Helper do the work to invoke the method
            MethodGroupHelper.invokeMethod( _service, getList_result,
                                   "flickr.interestingness.getList",
                                   false,
                                   new NameValuePair( "date", date ),
                                   new NameValuePair( "extras", extras ),
                                   new NameValuePair( "per_page", per_page.toString() ),
                                   new NameValuePair( "page", page.toString() ) );
        }

        private function getList_result( event:Event ):void {
            // Create a PHOTOS_GET_INTERESTINGNESS event
            var result:FlickrResultEvent = new FlickrResultEvent( FlickrResultEvent.PHOTOS_GET_INTERESTINGNESS );

            // Have the Helper handle parsing the result from the server - get the data
            // from the URLLoader which correspondes to the result from the API call
            trace(URLLoader( event.target ).data)
            MethodGroupHelper.processAndDispatch( _service,
                                                  URLLoader( event.target ).data,
                                                  result,
                                                  "photos",
                                                  MethodGroupHelper.parsePagedPhotoList );
        }
    }
}